<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css" media="all">
</head>
<body>
  <div style="margin: 20px;">
<form class="layui-form">
<input type="hidden" name="testpaper_id" value="{$testinfo.testpaper_id|default=''}">
<input type="hidden" name="courserclass_id" value="{$testinfo.courserclass_id|default=''}">
<label class="layui-form-label  lable-box">测试时间:</label>
      <div class="layui-form-pane">
       <div class="layui-input-inline">
         <input class="layui-input" placeholder="开始时间" id="start_time" name="start_time" value="{$testinfo.start_time|default=''}" style="height:30px; line-height:30px;"  readonly="true">
         </div>
         ——
         <div class="layui-input-inline">
          <input class="layui-input" placeholder="结束时间" id="end_time" name="end_time" value="{$testinfo.end_time|default=''}" style="height:30px; line-height:30px;" readonly="true">
        </div>
   </div>
   <div class="layui-form-item btn">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="test_btn">保存</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
</div>
<script type="text/javascript">
  var editurl = "{:U('Home/courseclassMgr/updatetest')}";
  var rooturl = "__ROOT__/";
</script>
<layuijs/>
</body>
</html>
<script type="text/javascript">
layui.use(['form','laydate'], function(){
  var form = layui.form(),
   laydate = layui.laydate,
  $ = layui.jquery;
  form.render(); //更新全部
  form.render('select');
 //监听提交
  var start = {
    istime: true, 
    format: 'YYYY-MM-DD hh:mm:ss', 
    festival: false,
      choose: function(datas){
        end.min = datas; //开始日选好后，重置结束日的最小日期
        end.start = datas //将结束日的初始值设定为开始日
      }
    };
    
    var end = {
      istime: true, 
    format: 'YYYY-MM-DD hh:mm:ss', 
    festival: false,
      choose: function(datas){
        start.max = datas; //结束日选好后，重置开始日的最大日期
      }
    };
    
    document.getElementById('start_time').onclick = function(){
      start.elem = this;
      laydate(start);
    }
    document.getElementById('end_time').onclick = function(){
      end.elem = this
      laydate(end);
    }
  form.on('submit(test_btn)', function(data) {
     // console.log(data.field);
    $.ajax({

      url: editurl,
      type: 'POST',
      data: data.field,
      error: function(request){
        layer.msg("请求服务器超时", {time: 1000, icon: 5});
      },
      success: function(data){
        if (data.success){
          layer.msg('提交成功', {
            time: 1000
          }, function(){
            parent.location.href="{:U('Home/courseclassMgr/courseclassList')}";
          });
        }else{
          layer.msg(data.msg, {
            time: 1000,icon:5
          });
        }
      }
    });
    
    return false;
  });
});
</script>

